package com.fm.base.domain.proxy;

import java.util.Objects;

public class HttpProxyProtocol implements ProxyProtocol {
	/**
	 * @value null not sure version
	 */
	public String version;

	/**
	 * @value null not sure support security
	 */
	public Boolean security;

	public HttpProxyProtocol(String version, Boolean security) {
		this.version = version;
		this.security = security;
	}

	@Override
	public boolean equals(Object obj) {
		return obj instanceof HttpProxyProtocol
			&& Objects.equals(version, ((HttpProxyProtocol) obj).version)
			&& Objects.equals(security, ((HttpProxyProtocol) obj).security);
	}

	@Override
	public String toString() {
		if (security == null) {
			if (version == null) {
				return "HTTP/HTTPS? ?";
			} else {
				return "HTTP/HTTPS? " + version;
			}
		} else if (security) {
			if (version == null) {
				return "HTTPS ?";
			} else {
				return "HTTPS " + version;
			}
		} else {
			if (version == null) {
				return "HTTP ?";
			} else {
				return "HTTP " + version;
			}
		}
	}
}
